Here, we are evaluating the ‘druggability’ of viper proteins that are well correlated with variables. The plots at the end of this are labeled by LVs, but the enrichment is actually based on the list of viper proteins that have a correlation of 0.5 or greater with LV expression across all tumors.

Import packages

First, import packages to process and plot the data.

library(dplyr)
library(tidyr)
library(readr)
library(synapser)
library(feather)
synLogin()
## Welcome, Sara Gosline!
## NULL
#get viper scores
viper_res <- synTableQuery('SELECT * FROM syn21259610')$filepath %>% 
readr::read_csv()%>%select(-c(ROW_ID,ROW_VERSION))
## 
Building the CSV... [###-----------------]14.21%   208612/1467984       
Building the CSV... [####----------------]21.74%   319133/1467984       
Building the CSV... [#######-------------]36.41%   534531/1467984       
Building the CSV... [#########-----------]43.77%   642485/1467984       
Building the CSV... [####################]100.00%   1467984/1467984   Done...    
Downloading  [--------------------]2.47%   2.0MB/81.0MB (3.5MB/s) Job-104751327485756097610485256.csv     
Downloading  [#-------------------]4.94%   4.0MB/81.0MB (5.7MB/s) Job-104751327485756097610485256.csv     
Downloading  [#-------------------]7.40%   6.0MB/81.0MB (7.0MB/s) Job-104751327485756097610485256.csv     
Downloading  [##------------------]9.87%   8.0MB/81.0MB (7.7MB/s) Job-104751327485756097610485256.csv     
Downloading  [##------------------]12.34%   10.0MB/81.0MB (8.6MB/s) Job-104751327485756097610485256.csv     
Downloading  [###-----------------]14.81%   12.0MB/81.0MB (9.3MB/s) Job-104751327485756097610485256.csv     
Downloading  [###-----------------]17.27%   14.0MB/81.0MB (9.9MB/s) Job-104751327485756097610485256.csv     
Downloading  [####----------------]19.74%   16.0MB/81.0MB (10.3MB/s) Job-104751327485756097610485256.csv     
Downloading  [####----------------]22.21%   18.0MB/81.0MB (10.7MB/s) Job-104751327485756097610485256.csv     
Downloading  [#####---------------]24.68%   20.0MB/81.0MB (11.0MB/s) Job-104751327485756097610485256.csv     
Downloading  [#####---------------]27.14%   22.0MB/81.0MB (11.4MB/s) Job-104751327485756097610485256.csv     
Downloading  [######--------------]29.61%   24.0MB/81.0MB (11.6MB/s) Job-104751327485756097610485256.csv     
Downloading  [######--------------]32.08%   26.0MB/81.0MB (11.8MB/s) Job-104751327485756097610485256.csv     
Downloading  [#######-------------]34.55%   28.0MB/81.0MB (12.0MB/s) Job-104751327485756097610485256.csv     
Downloading  [#######-------------]37.01%   30.0MB/81.0MB (12.2MB/s) Job-104751327485756097610485256.csv     
Downloading  [########------------]39.48%   32.0MB/81.0MB (12.4MB/s) Job-104751327485756097610485256.csv     
Downloading  [########------------]41.95%   34.0MB/81.0MB (12.6MB/s) Job-104751327485756097610485256.csv     
Downloading  [#########-----------]44.42%   36.0MB/81.0MB (12.7MB/s) Job-104751327485756097610485256.csv     
Downloading  [#########-----------]46.88%   38.0MB/81.0MB (12.8MB/s) Job-104751327485756097610485256.csv     
Downloading  [##########----------]49.35%   40.0MB/81.0MB (12.9MB/s) Job-104751327485756097610485256.csv     
Downloading  [##########----------]51.82%   42.0MB/81.0MB (13.1MB/s) Job-104751327485756097610485256.csv     
Downloading  [###########---------]54.29%   44.0MB/81.0MB (13.2MB/s) Job-104751327485756097610485256.csv     
Downloading  [###########---------]56.76%   46.0MB/81.0MB (13.3MB/s) Job-104751327485756097610485256.csv     
Downloading  [############--------]59.22%   48.0MB/81.0MB (13.3MB/s) Job-104751327485756097610485256.csv     
Downloading  [############--------]61.69%   50.0MB/81.0MB (13.4MB/s) Job-104751327485756097610485256.csv     
Downloading  [#############-------]64.16%   52.0MB/81.0MB (13.5MB/s) Job-104751327485756097610485256.csv     
Downloading  [#############-------]66.63%   54.0MB/81.0MB (13.6MB/s) Job-104751327485756097610485256.csv     
Downloading  [##############------]69.09%   56.0MB/81.0MB (13.7MB/s) Job-104751327485756097610485256.csv     
Downloading  [##############------]71.56%   58.0MB/81.0MB (13.7MB/s) Job-104751327485756097610485256.csv     
Downloading  [###############-----]74.03%   60.0MB/81.0MB (13.8MB/s) Job-104751327485756097610485256.csv     
Downloading  [###############-----]76.50%   62.0MB/81.0MB (13.9MB/s) Job-104751327485756097610485256.csv     
Downloading  [################----]78.96%   64.0MB/81.0MB (13.8MB/s) Job-104751327485756097610485256.csv     
Downloading  [################----]81.43%   66.0MB/81.0MB (13.9MB/s) Job-104751327485756097610485256.csv     
Downloading  [#################---]83.90%   68.0MB/81.0MB (14.0MB/s) Job-104751327485756097610485256.csv     
Downloading  [#################---]86.37%   70.0MB/81.0MB (14.0MB/s) Job-104751327485756097610485256.csv     
Downloading  [##################--]88.83%   72.0MB/81.0MB (14.1MB/s) Job-104751327485756097610485256.csv     
Downloading  [##################--]91.30%   74.0MB/81.0MB (14.1MB/s) Job-104751327485756097610485256.csv     
Downloading  [###################-]93.77%   76.0MB/81.0MB (14.2MB/s) Job-104751327485756097610485256.csv     
Downloading  [###################-]96.24%   78.0MB/81.0MB (14.2MB/s) Job-104751327485756097610485256.csv     
Downloading  [####################]98.70%   80.0MB/81.0MB (14.3MB/s) Job-104751327485756097610485256.csv     
Downloading  [####################]100.00%   81.0MB/81.0MB (14.3MB/s) Job-104751327485756097610485256.csv Done...
#get top LVs
top_lvs<-synTableQuery('SELECT distinct latent_var FROM syn21416832')$asDataFrame()$latent_var
## 
 [####################]100.00%   1/1   Done...    
Downloading  [####################]100.00%   1.3kB/1.3kB (2.5MB/s) Job-104751363312075609919947221.csv Done...
#get multiplier scores
mp_res <-synTableQuery("SELECT * from syn21046991 where tumorType <> 'NA'")$filepath %>%
  readr::read_csv()%>%
  select(latent_var,value,tumorType,specimenID,studyName)%>%
  subset(latent_var%in%top_lvs)
## 
Create CSV FileHandle [##########----------]50.58%   74936/148148       
Create CSV FileHandle [####################]100.00%   148148/148148   Done...    
Downloading  [##------------------]8.03%   2.0MB/24.9MB (3.8MB/s) Job-104751374834150053519231306.csv     
Downloading  [###-----------------]16.06%   4.0MB/24.9MB (5.3MB/s) Job-104751374834150053519231306.csv     
Downloading  [#####---------------]24.09%   6.0MB/24.9MB (6.3MB/s) Job-104751374834150053519231306.csv     
Downloading  [######--------------]32.12%   8.0MB/24.9MB (7.5MB/s) Job-104751374834150053519231306.csv     
Downloading  [########------------]40.15%   10.0MB/24.9MB (8.2MB/s) Job-104751374834150053519231306.csv     
Downloading  [##########----------]48.18%   12.0MB/24.9MB (8.9MB/s) Job-104751374834150053519231306.csv     
Downloading  [###########---------]56.21%   14.0MB/24.9MB (9.5MB/s) Job-104751374834150053519231306.csv     
Downloading  [#############-------]64.24%   16.0MB/24.9MB (10.0MB/s) Job-104751374834150053519231306.csv     
Downloading  [##############------]72.27%   18.0MB/24.9MB (10.3MB/s) Job-104751374834150053519231306.csv     
Downloading  [################----]80.30%   20.0MB/24.9MB (10.7MB/s) Job-104751374834150053519231306.csv     
Downloading  [##################--]88.33%   22.0MB/24.9MB (11.0MB/s) Job-104751374834150053519231306.csv     
Downloading  [###################-]96.36%   24.0MB/24.9MB (11.1MB/s) Job-104751374834150053519231306.csv     
Downloading  [####################]100.00%   24.9MB/24.9MB (11.2MB/s) Job-104751374834150053519231306.csv Done...
#get drug targets
drug_targets <- feather::read_feather(synGet('syn20700199')$path)
drug_targets <- drug_targets %>% 
  filter(mean_pchembl > 7) %>% 
  mutate(gene= hugo_gene) %>% 
  select(gene, std_name) 

Map drugs and targets to summarize mapping

For each drug we want to compute the mean metaviper score of each of its targets in each of the samples to provide a per-sample analysis of drug efficacy.

term2viper <- drug_targets %>% 
  mutate(term = std_name) %>% 
  select(term, gene) %>% 
  distinct()%>%
  left_join(viper_res,by='gene')

library(ggplot2)
drugTargs<-term2viper%>%
  group_by(term)%>%
  summarize(numTargs=n_distinct(gene))
 
ggplot(drugTargs)+geom_bar(aes(x=numTargs))

Most drugs have only 1 target! Let’s filter to those drugs that have at least 3 targets

Calculate mean drug metaviper values and correlation with LV

topDrugs<-subset(drugTargs,numTargs>2)%>%
  select(term)

drugMeans<-term2viper%>%
  subset(term%in%topDrugs$term)%>%
  group_by(term,specimenID)%>%
  summarize(meanViper=mean(metaviperscore))

lv2drug<-drugMeans%>%
  ungroup()%>%
  left_join(mp_res,by='specimenID')

corLvs<-lv2drug%>%
  group_by(latent_var,term)%>%
  summarize(lvDrugCor=cor(value,meanViper,method='spearman'))%>%
  subset(abs(lvDrugCor)>0.65)%>%left_join(drugTargs,by='term')

DT::datatable(corLvs)

There are sooo mnay drugs/LVs that are correlated. This is likely due to the high amount of overlap with drugs and targets.

Filtering for significant drug/lv combos

Since Robert calculated the enrichment of each LV by drug targets in syn21442304 we can select those with significant (p.adjust<0.01) enrichment that also have drugs that are somewhat recognizable (not CHEMBL ids or some form of Acid)

sigs<-synTableQuery("SELECT * from syn21442304 where \"p.adjust\"<0.01 and ID not like 'CHEMBL%' and ID not like '%Acid'")$asDataFrame()%>%
  select(-c(ROW_ID,ROW_VERSION))
## 
 [####################]100.00%   1/1   Done...    
Downloading  [####################]100.00%   12.2kB/12.2kB (545.1kB/s) Job-104751555414347538112607293.csv Done...
res=sapply(unique(sigs$latent_var),function(lv){
  drugs<-subset(sigs,latent_var==lv)%>%
    select(ID)%>%
    distinct()
  
  terms=subset(corLvs,latent_var==lv)%>%ungroup()%>%select(term)%>%distinct()
  toplot=subset(lv2drug,latent_var==lv)%>%
    subset(term%in%drugs$ID)%>%
    subset(term%in%terms$term)%>%
    rename(`LV Score`='value')
      
  toplot$term<-droplevels(toplot$term)
  p<-ggplot(toplot)+geom_point(aes(x=meanViper,y=`LV Score`,col=term,shape=tumorType))+
    ggtitle(paste(lv,'correlated drugs by Viper score'))+theme_bw()
  print(p)
  ggsave(paste(lv,'corDrugs.pdf',sep=''),useDingbats=FALSE)
  p
})

sessionInfo()
## R version 3.5.0 (2018-04-23)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS  10.14.6
## 
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ggplot2_3.2.1   feather_0.3.5   synapser_0.6.61 readr_1.3.1    
## [5] tidyr_1.0.0     dplyr_0.8.3    
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.3            later_1.0.0           pillar_1.4.2         
##  [4] compiler_3.5.0        PythonEmbedInR_0.3.37 tools_3.5.0          
##  [7] zeallot_0.1.0         digest_0.6.23         jsonlite_1.6         
## [10] evaluate_0.14         lifecycle_0.1.0       tibble_2.1.3         
## [13] gtable_0.3.0          pkgconfig_2.0.3       rlang_0.4.2          
## [16] shiny_1.4.0           crosstalk_1.0.0       yaml_2.2.0           
## [19] xfun_0.11             fastmap_1.0.1         withr_2.1.2          
## [22] stringr_1.4.0         knitr_1.26            htmlwidgets_1.5.1    
## [25] vctrs_0.2.0           hms_0.5.2             DT_0.10              
## [28] grid_3.5.0            tidyselect_0.2.5      glue_1.3.1           
## [31] R6_2.4.1              rmarkdown_1.17        farver_2.0.1         
## [34] purrr_0.3.3           magrittr_1.5          promises_1.1.0       
## [37] backports_1.1.5       scales_1.1.0          codetools_0.2-16     
## [40] htmltools_0.4.0       assertthat_0.2.1      xtable_1.8-4         
## [43] mime_0.7              colorspace_1.4-1      httpuv_1.5.2         
## [46] labeling_0.3          stringi_1.4.3         pack_0.1-1           
## [49] lazyeval_0.2.2        munsell_0.5.0         crayon_1.3.4